﻿namespace BM.Tools.WebControls.MForm.Navigation
{
    using System.Collections.Generic;

    using BM.Tools.WebControls.MForm.Controls.Items;

    /// <summary>
    /// The implementation of the  <see cref="NavigatorQuery{T}"/> for the <see cref="OffspringItem" /> objects.
    /// </summary>
    public class OffspringQuery : NavigatorQuery<OffspringItem>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="OffspringQuery"/> class. 
        /// </summary>
        /// <param name="item">
        /// The offspring item.
        /// </param>
        public OffspringQuery(OffspringItem item) : base(item)
        {
        }

        /// <summary>
        /// Gets DescendantsAndSelf.
        /// </summary>
        /// <value>
        /// The descendants and self.
        /// </value>
        public override IEnumerable<OffspringItem> DescendantsAndSelf
        {
            get
            {
                return Item.GetDescendantsAndSelf();
            }
        }

        /// <summary>
        /// Returns items' children.
        /// </summary>
        /// <returns>
        /// Items' children.
        /// </returns>
        public override IEnumerable<OffspringItem> FindChildren()
        {
            return Item.FindChildren();
        }

        /// <summary>
        /// finds all the children with a local name 
        /// </summary>
        /// <param name="localName">
        /// The local name.
        /// </param>
        /// <returns>
        /// the enumeration of children with a local name
        /// </returns>
        public override IEnumerable<OffspringItem> FindChildrenByLocalName(string localName)
        {
            return Item.FindChildrenByLocalName(localName);
        }

        /// <summary>
        /// finds all the children with a name 
        /// </summary>
        /// <param name="name">
        /// The name to be checked.
        /// </param>
        /// <returns>
        /// the enumeration of children with a name
        /// </returns>
        public override IEnumerable<OffspringItem> FindChildrenByName(string name)
        {
            return Item.FindChildrenByName(name);
        }

        /// <summary>
        /// finds all the children with a prefix
        /// </summary>
        /// <param name="prefix">
        /// The prefix.
        /// </param>
        /// <returns>
        /// the enumeration of children with a prefix
        /// </returns>
        public override IEnumerable<OffspringItem> FindChildrenByPrefix(string prefix)
        {
            return Item.FindChildrenByPrefix(prefix);
        }

        /// <summary>
        /// Returns items' parent.
        /// </summary>
        /// <returns>
        /// Items' parent.
        /// </returns>
        public override OffspringItem FindParent()
        {
            return Item.ParentItem;
        }

        /// <summary>
        /// checks if item position equals the specified value
        /// </summary>
        /// <param name="position">
        /// The position to be compared to.
        /// </param>
        /// <returns>
        /// does the position equal the specified value
        /// </returns>
        public override bool IndexEquals(int position)
        {
            return position == Item.Index;
        }

        /// <summary>
        /// returns information if the item is attribute
        /// </summary>        
        /// <returns>
        /// is item attribute
        /// </returns>
        public override bool IsAttribute()
        {
            return Item.IsAttribute();
        }

        /// <summary>
        /// returns information if the item is element
        /// </summary>        
        /// <returns>
        /// is item element
        /// </returns>
        public override bool IsElement()
        {
            return Item.IsElement();
        }

        /// <summary>
        /// checks if item name equals the specified value
        /// </summary>
        /// <param name="name">
        /// The name to be compared to.
        /// </param>
        /// <returns>
        /// does the name equal the specified value
        /// </returns>
        public override bool NameEquals(string name)
        {
            return Item.NameEquals(name);
        }
    }
}